<?php

namespace App\Console\Commands\Tools;

use App\Kuafu\Pay\BasePay;
use App\Kuafu\Pay\Channel\FuYou\FuYouBase;
use App\Kuafu\Pay\Service\PayService;
use App\Kuafu\WaiMai\Enum\WaiMaiDBEnum;
use App\Library\FeiShu\SendFs;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Log;

class OrderRefundCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'order:refundOrder';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '订单操作:退款';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command
     *
     * @return int
     *
     */
    public function handle()
    {


//        $payStream = PayStreamModel::query()->where('orderId', '120401283042512698')->first();

//        $result1 = BasePay::instance(2, 0, 4)->refund(
//            '202203211742591795895631', '5000000'
////        );
//        $result2 = BasePay::instance(4, 13169, 1)->refund(
//            '10000202207111947450992779332', 5000
////            '202203211743431795942936', 2680000
//        );
////
////        var_dump($result1);
//        var_dump($result2);


//        $result = BasePay::instance(2, 0, 4)->refund(
//            '4200001314202203176957237188', '8400'
//        );
//
//
//        var_dump($result);
//        die;

//        $refund = BasePay::instance(4, 12010)->refund('9818202202011612090759763146', 3468);
//        $refund = BasePay::instance(PayStreamModel::PAY_CHANNEL_FY, 21)->refund('9714202203081601511558807906', 990);

//        $refundStatus =  BasePay::instance(4, 12010)->refundQuery('9818202202011612090759763146', '9818202202011612090759763146');
//        $result = PayService::sRefund(
//            12010,
//            '62364982255291257',
//            '3468',
//            '',
//            3
//        );
//        dd($refund);
//
//        die;
        // 62364982255291257 2022年02月01日
//        if (config(' 2022年02月01日 app.env') == 'dev') {
//            $time      = date('Ymd');
//            $startTime = strtotime($time);
//
//            $paySteam = PayStreamModel::query()
//                                      ->where('createdAt', '>', $startTime)
//                                      ->where('payChannel', '<>', 3)
//                                      ->get()
//                                      ->toArray();
//
//            foreach ($paySteam as $pay) {
//                PayService::sRefund($pay['shopId'], $pay['orderId'], $pay['payPrice']);
//            }
//            die('好了');
//        } else {
//            die('不是测试环境');
//        }

//        for ($i = 0; $i <= 99; $i++) {
        // 优惠券退券
//            $res = OrderCouponExtSplitModel::suffix($i)->where('couponStatus', 1)->get();
//            foreach ($res as $v) {

//            }
//        }

    }
}
